const { getLogger, configure } = require('log4js')
const { join } = require('path')
const config = require('../config')
configure({
  appenders: {
    app: {
      type: 'dateFile',
      filename: join(__dirname, '../../logs/app'),
      pattern: 'yyyy.MM.dd.log',
      maxLogSize: 10 * 1024 * 1024,
      numBackups: 3,
      alwaysIncludePattern: true
    }
  },
  categories: {
    default: {
      appenders: ['app'],
      level: config.logLevel || 'debug'
    }
  }
})
const logger = getLogger()

module.exports = logger